package com.glhtgyxy.biyesheji.Mapper;

import com.glhtgyxy.biyesheji.Pojo.merchant;
import com.glhtgyxy.biyesheji.Pojo.user;

import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface merchantMapper {

    @Select("select * from merchant")
    ArrayList<merchant> findAllMerchant();

    @Delete("delete from merchant where id = #{id}")
    int deleteMerchant(@Param("id") int id);


    @Delete("delete from house where id = #{houseid}")
    int shanchufangyuan(int houseid);

    @Update("update merchant set merchantname=#{name} , merchantaccount=#{account} , merchantpassword=#{password} where id = #{id}")
    int updateMerchant(@Param("id") int id, @Param("name") String name,
                        @Param("account") String account, @Param("password") String password);


    @Insert("insert into merchant (merchantname,merchantaccount,merchantpassword) values (#{name},#{account},#{password})")
    int addMerchant(@Param("name") String name,
                @Param("account") String account,
                @Param("password") String password);

    @Select("SELECT * FROM merchant WHERE id LIKE CONCAT('%', #{searchtext}, '%') OR merchantname LIKE CONCAT('%', #{searchtext}, '%') OR merchantaccount LIKE CONCAT('%', #{searchtext}, '%') OR merchantpassword LIKE CONCAT('%', #{searchtext}, '%')")
    ArrayList<merchant> findMerchant(@Param("searchtext") String searchtext);

    @Insert("insert into house (housename,addr,price,bedroom,facilityservices,image,masterid) values (#{housename},#{addr},#{price},#{bedroom},#{service},#{imgname},#{masterid})")
    int merchantaddhouse(
            String housename,
            String addr,
            String price,
            String bedroom,
            String service,
            String imgname,
            int masterid
    );


}
